﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Fofia.ObjectPool
{
    /// <summary>
    /// 对象池属性
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PoolOption<T> where T : class, new()
    {

        /// <summary>
        /// 池子最小数量
        /// </summary>
        public int MinSize { get; set; } = 1;
        /// <summary>
        /// 对象池大小
        /// </summary>
        public int PoolSize { get; set; } = 10;

        /// <summary>
        /// 获取对象超时时长
        /// </summary>
        public TimeSpan BorrowTimeout { get; set; } = TimeSpan.FromSeconds(10);

        /// <summary>
        /// 对象归还超时时长-默认60秒
        /// </summary>
        public int ReturnObjectTimeout = 60;

        /// <summary>
        /// 对象长时间未使用 过期时间-默认30秒
        /// </summary>
        public int Expiration { get; set; } = 30;
        /// <summary>
        /// 对象初始化器
        /// </summary>
        public Func<T> ObjectGenerator { get; set; }= () => new T();
    }
}
